package org.alps.pattern.observer.circle;

import java.util.Observable;

/**
 *
 * GP生态圈：被观察者
 * JDK提供的一种观察者实现方式
 * @date 2021-05-01
 * @author zkw
 */
public class GpCircle extends Observable {
    private GpCircle() { }

    private String name = "GP生态圈";

    private static GpCircle gpCircle = null;

    public static GpCircle getInstance() {
        if (gpCircle == null) {
            gpCircle = new GpCircle();
        }
        return gpCircle;
    }

    public String getName() {
        return name;
    }

    /**
     * 提问
     * @param question
     */
    public void publishQuestion(Question question) {
        System.out.println(question.getUserName() + "在" + this.name + "上提交了一个问题。");
        setChanged();
        notifyObservers(question);
    }

}
